#!/usr/bin/env python
#-*- coding: utf-8 -*-
#
# Copyright 2013 Antoine Drouin (poinix@gmail.com)
#
# This file is part of PAT.
#
#    PAT is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    PAT is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with PAT.  If not, see <http://www.gnu.org/licenses/>.
#

"""
 Demonstration of the DynamicModel object for the planar VTOL vehicle
"""

import numpy as np
import matplotlib.pyplot as plt

import pat.vehicles.rotorcraft.dynamic_model_planar_simple as dm

my_dm = dm.DynamicModel()
Xe, Ue = my_dm.trim()

dt = 0.01; time = np.arange(0., 1., dt)
X = np.zeros((len(time), dm.sv_size))
X[0] = my_dm.X
for i in range(1,len(time)):
    X[i] = my_dm.run(dt, Ue)

my_dm.plot_state(time, X, window_title="Open loop simulation of the planar VTOL",
                 filename="../doc/images/wiki/planar_vtol_open_loop.png")
plt.show()
